Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RmdirContents API in the Fileystem v2alpha1 API Group #186

Merged

Conversation

mauriciopoppe
Copy link
Member

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change
/kind feature

What this PR does / why we need it:
Adds the new Filesystem API, RmdirContents, it removes the contents of a directory (but not the directory itself).

Does this PR introduce a user-facing change?:

Add Filesystem API RmdirContents to remove the contents of a directory.

/cc @jingxu97 @ddebroy

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 6, 2022
@mauriciopoppe mauriciopoppe force-pushed the rmdircontents-filesystem-api branch 3 times, most recently from 50caaff to f1d1bf8 Compare January 6, 2022 23:57
Copy link
Contributor

@ddebroy ddebroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommend starting a v2beta1 API group in filesystem for the new changes.

client/api/filesystem/v1/api.proto Outdated Show resolved Hide resolved
@mauriciopoppe mauriciopoppe force-pushed the rmdircontents-filesystem-api branch from f1d1bf8 to 3af8237 Compare January 7, 2022 21:02
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 7, 2022
@mauriciopoppe mauriciopoppe force-pushed the rmdircontents-filesystem-api branch 3 times, most recently from 3544eec to 1842fce Compare January 7, 2022 21:15
@mauriciopoppe mauriciopoppe changed the title Add RmdirContents API in the Fileystem API Group Add RmdirContents API in the Fileystem v2alpha1 API Group Jan 7, 2022
@mauriciopoppe
Copy link
Member Author

/hold

Needs #187 to be merged first.

@ddebroy please take a look again, I generated the files on top of a new api version v2alpha1.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 7, 2022
@ddebroy
Copy link
Contributor

ddebroy commented Jan 8, 2022

Thanks!

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 8, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ddebroy, mauriciopoppe

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 8, 2022
@mauriciopoppe mauriciopoppe force-pushed the rmdircontents-filesystem-api branch from 1842fce to 78eb1b3 Compare January 8, 2022 05:27
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jan 8, 2022
if err != nil {
return err
}
for _, file := range files {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you didn't implement force option here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, fixed

@mauriciopoppe mauriciopoppe force-pushed the rmdircontents-filesystem-api branch from 3571adc to fd5fdae Compare January 11, 2022 18:16
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 11, 2022
@mauriciopoppe
Copy link
Member Author

/hold

#187 was merged and I'll try with the prow integration test job too.

@mauriciopoppe
Copy link
Member Author

/test pull-kubernetes-csi-csi-proxy-integration

@mauriciopoppe mauriciopoppe force-pushed the rmdircontents-filesystem-api branch 3 times, most recently from 38089c9 to a9faf8e Compare January 27, 2022 01:20
@mauriciopoppe
Copy link
Member Author

/remove-hold
@jingxu97 this is ready for review, please take a look :)

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 27, 2022
string path = 1;

// Force remove all contents under path (if any).
bool force = 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we want to have this option? If force is false, it can only remove files, or empty dirs?
Does RmdirContents mean we want to remove everything under it, not just empty dirs?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good observation, from LVP it's always called with force = true and if it's false then it's like you say for, this is because I copied the message from the existing Rmdir message

I removed the field

@mauriciopoppe mauriciopoppe force-pushed the rmdircontents-filesystem-api branch from a9faf8e to f16a115 Compare January 27, 2022 22:55
@mauriciopoppe
Copy link
Member Author

/test pull-kubernetes-csi-csi-proxy-integration

@mauriciopoppe mauriciopoppe force-pushed the rmdircontents-filesystem-api branch from f16a115 to 897656b Compare January 27, 2022 22:57
@mauriciopoppe
Copy link
Member Author

/test pull-kubernetes-csi-csi-proxy-integration

@@ -15,6 +15,9 @@ service Filesystem {
// This may be used for unlinking a symlink created through CreateSymlink.
rpc Rmdir(RmdirRequest) returns (RmdirResponse) {}

// RmdirContents removes the contents of a directory in the host filesystem.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add a few more words to mention contents are all the files and sub dirs under the dir. The directory itself will not be deleted.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added:

    // Unlike Rmdir it won't delete the requested path, it'll only delete its contents.

@@ -78,6 +80,29 @@ func (filesystemAPI) Rmdir(path string, force bool) error {
return os.Remove(path)
}

// RmdirContents removes the contents of a directory with `os.RemoveAll`
func (filesystemAPI) RmdirContents(path string) error {
dir, err := os.Open(path)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://stackoverflow.com/a/52685448

a reference of implementation

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took the same implementation as LVP for linux

@mauriciopoppe mauriciopoppe force-pushed the rmdircontents-filesystem-api branch from 897656b to b5442d7 Compare January 28, 2022 00:16
@mauriciopoppe
Copy link
Member Author

/test pull-kubernetes-csi-csi-proxy-integration

@jingxu97
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 28, 2022
@k8s-ci-robot k8s-ci-robot merged commit 50d3996 into kubernetes-csi:master Jan 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants